﻿package {
	import flash.display.MovieClip;
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.display.Stage;
	import flash.text.TextField;
  
	import _Content.scene_manage;
	import _Content.scene_data;
	import _Content.key_control;


	
    // --------------MSN:lation_pan@live.cn  QQ: 3423526------------- //

    public class main extends MovieClip {
		
		private var _Down_code:Number = 0
		private var _key_control:key_control=new key_control()
		public function main() {
			//_Cam=scene_data._Cam3D
			scene_data._focus_3d.angle_y = 0;
			scene_data._focus_3d.angle_x = -20;
			scene_data._focus_3d.z = 0
			scene_data._Cam3D._distance = -scene_data._Cam3D._br;
			scene_data._Cam3D._distance =200

			this.addChild(scene_data._all_mc);
			
			scene_manage._push_3dmove( { name:"Pan", et:"people01", x: 0, y:10, z:0, angle_y:180, level:1,roadarray:[{x:0,z:0},{x:200,z:250},{x:500,z:0} ,{x:1400,z:0},{x:1600,z:-200},{x:1600,z:250},{x:1300,z:-200},{x:1100,z:0},{x:400,z:0},{x:0,z:-300},{x:0,z:-1000},{x:-100,z:-1100},{x:-200,z:-1200},{x:-250,z:-1400},{x:-200,z:-1500},{x:-100,z:-1600},{x:0,z:-1650},{x:100,z:-1600},{x:200,z:-1500},{x:250,z:-1400},{x:200,z:-1300},{x:100,z:-1200},{x:0,z:-1100}] } );
			
            scene_manage._push_3dobj( { name:"A_ground",et:"ground01", x: 0, y:0, z:-1400, angle_y:0, level:4 } );
			scene_manage._push_3dobj( { name:"A_top",et:"ceiling", x: 0, y:300, z:-1400, angle_y:0, level:1 } );
			scene_manage._push_3dobj( { name:"A_wall_a",et:"ville_wall03", x: 0, y:0, z:-900, angle_y:0, level:1 } );
			scene_manage._push_3dobj( { name:"A_wall_b",et:"ville_wall02", x:-500, y:0, z:-1400, angle_y:90, level:1 } );
			scene_manage._push_3dobj( { name:"A_wall_c",et:"ville_wall01", x:0, y:0, z:-1900, angle_y:180, level:1 } );
			scene_manage._push_3dobj( { name:"A_wall_d", et:"ville_wall02", x:500, y:0, z: -1400, angle_y: -90, level:1 } );
			scene_manage._push_3dobj( { name:"A_box001",et:"box01", x:-0, y:0, z:-1400, angle_y:0, level:1 } );
	
		

			
			scene_manage._push_3dobj( { name:"B_ground",et:"ground02", x: 0, y:0, z:-700, angle_y:0, level:4 } );
			scene_manage._push_3dobj( { name:"B_top",et:"ceiling02", x: 0, y:150, z:-700, angle_y:0, level:1 } );
            scene_manage._push_3dobj( { name:"B_wall_a", et:"ville_wall04", x: -100, y:0, z:-700, angle_y:90, level:1 } );
            scene_manage._push_3dobj( { name:"B_wall_b", et:"ville_wall04", x: 100, y:0, z:-700, angle_y: -90, level:1 } );
			
			scene_manage._push_3dobj( { name:"C_ground", et:"ground01", x: 0, y:0, z:0, angle_y:0, level:4 } );
			scene_manage._push_3dobj( { name:"C_top",et:"ceiling", x: 0, y:300, z:0, angle_y:0, level:1 } );
			scene_manage._push_3dobj( { name:"C_wall_a", et:"ville_wall01", x: 0, y:0, z:500, angle_y:0, level:1 } );
			scene_manage._push_3dobj( { name:"C_wall_b", et:"ville_wall02", x: -500, y:0, z:0, angle_y:90, level:1 } );
			scene_manage._push_3dobj( { name:"C_wall_d", et:"ville_wall03", x:500, y:0, z:0, angle_y: -90, level:1 } );
			scene_manage._push_3dobj( { name:"C_wall_c", et:"ville_wall03", x: 0, y:0, z:-500, angle_y:180, level:1 } );
			scene_manage._push_3dobj( { name:"C_box001",et:"box01", x:-100, y:0, z:100, angle_y:0, level:1 } );
	
			
			
			scene_manage._push_3dobj( { name:"D_ground", et:"ground02", x: 700, y:0, z:0, angle_y:90, level:4 } );
			scene_manage._push_3dobj( { name:"D_top",et:"ceiling02", x: 700, y:150, z:0, angle_y:90, level:1 } );
            scene_manage._push_3dobj( { name:"D_wall_a", et:"ville_wall04", x: 700, y:0, z:100, angle_y:0, level:1 } );
            scene_manage._push_3dobj( { name:"D_wall_b", et:"ville_wall04", x: 700, y:0, z:-100, angle_y: 180, level:1 } );
			
			scene_manage._push_3dobj( { name:"E_ground", et:"ground01", x: 1400, y:0, z:0, angle_y:0, level:4 } );
			scene_manage._push_3dobj( { name:"E_top", et:"ceiling", x:1400, y:300, z:0, angle_y:0, level:1 } );
			scene_manage._push_3dobj( { name:"E_wall_a", et:"ville_wall01", x: 1400, y:0, z:500, angle_y:0, level:1 } );
			scene_manage._push_3dobj( { name:"E_wall_b", et:"ville_wall03", x: 900, y:0, z:0, angle_y:90, level:1 } );
			scene_manage._push_3dobj( { name:"E_wall_c", et:"ville_wall02", x: 1400, y:0, z:-500, angle_y:180, level:1 } );
			scene_manage._push_3dobj( { name:"E_wall_d", et:"ville_wall01", x: 1900, y:0, z:0, angle_y:-90, level:1 } );
	
			
			stage.addEventListener(Event.ENTER_FRAME, _on_Enter_Frame)

	        _key_control.init(stage)
			
			this.setChildIndex(scene_data._all_mc, 0);
			stage.addEventListener(MouseEvent.MOUSE_WHEEL,_on_Mouse_Wheel)
			
		}
        private function _on_Mouse_Wheel(evt:MouseEvent) {
			scene_data._Cam3D._distance = scene_data._Cam3D._distance + 10 * evt.delta;
		}
		private function _on_Enter_Frame(evt:Event) {
			scene_data._focus_3d.angle_y = mouseX
			for (var i in scene_data._Stat_item) {
				if (scene_data._Stat_item[i]._name == "Pan") {
					scene_data._focus_3d.x=scene_data._Stat_item[i].x
					scene_data._focus_3d.y=scene_data._Stat_item[i].y
					scene_data._focus_3d.z=scene_data._Stat_item[i].z
				}
			}
			_up_data()
			t_txt.text = "x:" + String(int(scene_data._Cam3D.x)) + "   y: " + String(int(scene_data._Cam3D.y)) + "   z:" + String(int(scene_data._Cam3D.z)) + "   angle_x:  " + String(int(scene_data._Cam3D.angle_x))+ "   angle_y:  " + String(int(scene_data._Cam3D.angle_y))

		}


		
		public function _up_data() {
			scene_manage._catch_cam(scene_data._Cam3D, scene_data._focus_3d);
			for (var i in scene_data._Stat_item) {
				scene_data._Stat_item[i]._mc._up_data()
			}
			scene_manage._set_stat_level() 
		}


	}
	
}